body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
}

.center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-style: preserve-3d;
  perspective: 200px;
  border: 2px solid #000;
  width: 100px;
  height: 40px;
  border-radius: 40px;
}

input[type="checkbox"] {
  position: relative;
  width: 100px;
  height: 40px;
  margin: 0;
  appearance: none;
  -moz-appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: .5s;
  cursor: pointer;
}

span {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  line-height: 40px;
  text-align: center;
  text-transform: uppercase;
  font-weight: bold;
  color: #fff;
  pointer-events: none;
  transform-style: preserve-3d;
}
span:nth-child(2){
  left: 0;
  border-top-left-radius: 40px;
  border-bottom-left-radius: 40px;
  background: #0f0;
}
span:nth-child(2)::before{
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  border-top-left-radius: 40px;
  border-bottom-left-radius: 40px;
  background:linear-gradient(90deg,#f00,#de0808);
  transform-origin: right;
  transition: 1s;
  backface-visibility: hidden;
}
input[type="checkbox"]:checked ~
span:nth-child(2)::before{
  transform: rotateY(180deg);
}
span:nth-child(3){
  right: 0;
  border-top-right-radius: 40px;
  border-bottom-right-radius: 40px;
  background: #f00;
}
span:nth-child(3)::before{
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-top-right-radius: 40px;
  border-bottom-right-radius: 40px;
  background:linear-gradient(90deg,#0cd20c,#0f0);
  transform-origin: left;
  transition: 1s;
  backface-visibility: hidden;
  transform: rotateY(180deg);
}
input[type="checkbox"]:checked ~
span:nth-child(3)::before{
  transform: rotateY(360deg);
}
